local pianan = fk.CreateSkill{
  name = "mod__pianan",
  frequency = Skill.Compulsory,
}
local pianan_ = {
  anim_type = "defensive",
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(self) and (event == fk.GameStart or (target == player and player.phase == Player.Discard))
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local cids = player.player_cards[Player.Hand] or {}
    local cards = {}
    if #cids > 0 then
      for _, id in ipairs(cids) do
        if Fk:getCardById(id).trueName ~= "jink" then
          table.insertIfNeed(cards, id)
        end
      end
      if #cards > 0 then
        room:throwCard(cards, self.name, player, player)
      end
    end
    local pile = table.filter(room.draw_pile, function(id)
      return Fk:getCardById(id).name == "jink" 
    end) or {}
    for _, id in ipairs(room.discard_pile) do
      if Fk:getCardById(id).name == "jink" then
        table.insertIfNeed(pile, id)
      end
    end
    cids = player.player_cards[Player.Hand] or {}
    for i = 1, #pile do
      if #cids >= player.hp then break end
      room:obtainCard(player, pile[i], false, fk.ReasonPrey, player.id)
      cids = player.player_cards[Player.Hand] or {}
    end
  end,
}
pianan:addEffect(fk.GameStart, pianan_)
pianan:addEffect(fk.EventPhaseEnd, pianan_)
return pianan